
Ext.define('demo.view.bookwin',{
	 extend: 'Ext.window.Window',
	 alias : 'widget.dbwin',
	 
	 title:'图书信息添加',
	 layout:'fit',
	 autoShow: true,
     width: 280,
     height:300,
	 modal:true,
	
	  initComponent:function(){
	  		this.items=[
	  			{
	  				xtype:'form',
	  				id:'InformationForm',
	  				padding: '5 5 0 5',
                	border: false,
                	style: 'background-color: #fff;',
                	items:[
	                	{
	                        xtype: 'textfield',
	                        name : 'BookNum',
	                        fieldLabel: '图书编号'
	                    },
	                    {
	                        xtype: 'textfield',
	                        name : 'BookName',
	                        fieldLabel: '图书名称'
	                    },{
	                	
	                        xtype: 'triggerfield',
	                        name : 'BookPress',
	                        fieldLabel: '出版社',
	                        onTriggerClick:function(){
	                        	var win = Ext.create('demo.view.presswin');
	                        	win.show();
	                        	var grid = win.down('grid');
	                        	
	                        	win.down('button').addListener('click',function(btn){
	                        		var data = grid.getSelectionModel().getSelection()[0];
	                        		if(data == null){
    									Ext.Msg.alert('提示','你没有选择数据！');
    									return;
    								}
	                        		var basic = Ext.getCmp('InformationForm');
	                        		basic.getForm().findField('BookPress').setValue(data.data.BookPress);
	                        		win.close();
	                        	})
	                        	
	                        }
	                    },
	                    {
	                        xtype: 'combobox',
	                        name : 'BookClassify',
	                        fieldLabel: '图书分类',
	                        store:new Ext.data.ArrayStore({
	                        	fields: ['id', 'name'],
	                        	data: [[1, '经典'], [2, '惊悚'], [3, '其他']]
	                        }),
	                        queryMode:'local',
	                        valueField:'name',
	                        displayField:'name'
	                    },{
	                        xtype: 'textfield',
	                        name : 'BookPrice',
	                        fieldLabel: '图书价格'
	                    }
                	]
	  			}
	  		];
	  		
	  	   this.buttons=[
		  	    {
	                text: '保存',
	                action: 'save'
	            },
	            {
	                text: '取消',
	                scope: this,
	                handler: this.close
	            }
	  	   ];
	  	   
	  	   this.callParent(arguments);
	  }
	
})
